/*
* Copyright (c) 2025 -present FengJinjian ( 751965763@qq.com )
*/
import { request } from "@/utils/request/index";
import type {ListResult} from "@/api/model/listModel";
/**
 * ${table.comment!} 接口
 */
export interface ${entity}Info {
<#list table.fields as field>
    <#if field.propertyName != "id">
        <#if field.propertyType == "String" || field.propertyType == "Date">
            ${field.propertyName}?: string;
        <#elseif field.propertyType == "Integer" || field.propertyType == "Long">
            ${field.propertyName}?: number;
        <#elseif field.propertyType == "Boolean">
            ${field.propertyName}?: boolean;
        <#else>
            ${field.propertyName}?: any;
        </#if>
    </#if>
</#list>
}

export interface ApiResponse<T> {
    code: number;
    message: string;
    data: T;
    }
export type ${entity}Response = ApiResponse<number>; // 新创建的合同ID



enum ${entity}Api {
  Page = '/${moduleName}/',
  Create = '/${moduleName}/',
  Update = '/${moduleName}',
  Delete = '/${moduleName}',
  Detail = '/${moduleName}/detail',
}

/**
 * 获取${table.comment!}列表
 */
export const get${entity}List = (params: ${entity}Info ) => {
  return request.get<${entity}Response>({
    url: ${entity}Api.Page,
    params,
  });
};

/**
 * 创建${table.comment!}
 */
export const create${entity} = (params: ${entity}Info) => {
  return request.post({
    url: ${entity}Api.Create,
    params,
  });
};

/**
 * 更新${table.comment!}
 */
export const update${entity} = (params: ${entity}Info) => {
  return request.put({
    url: ${entity}Api.Update+`/`+params.id,
    params,
  });
};

/**
 * 删除${table.comment!}
 */
export const delete${entity} = (id: number) => {
  return request.delete({
    url: ${entity}Api.Delete+`/`+id
  });
};

/**
 * 获取${table.comment!}详情
 */
export const get${entity}Detail = (id: number) => {
  return   request.get<${entity}Info>({
    url: ${entity}Api.Detail,
    params: { id },
  });
};